<?php
/**
  * 管理登录入口
  * login.php
  * 模板文件：login.html
  */
include_once("global_login.php");
include_once("functions/operator.php");

$operatorObj = new operator;

//$DB->debug = true;
//取得参数
$user 	= $_REQUEST["username"];
$pwd 	= md5($_REQUEST["password"]);
$chk	= intval($_REQUEST["chk"]);
//

if($chk == 1) {	
	$login_status = $operatorObj->logincheck($user,$pwd);
	//status:1验证通过，2帐号停用，3密码错误，4帐号不存在
	if($login_status == 1){
		$url = "admin.php";
		header("location:$url");		
	}elseif($login_status == 2){
		$errmsg	= "帐号已经停用！";
	}elseif($login_status == 3) {
		$errmsg = "密码错误！";
	}else{
		$errmsg = "帐号不存在！";
	}	
}

//模板设置
$smarty = $COMMON->template_init();

$smarty -> assign(array(
		"errmsg"	 => $errmsg,
		"userName"	 => $user,
		));

$smarty->display("login.html");
?>